from django.db import models

# Create your models here.
from django.contrib.auth.models import AbstractUser, UserManager as _Usermanager


class UserManager(_Usermanager):
    def create_superuser(self, username, password, email=None, **extra_fields):
        super().create_superuser(username=username,
                                 password=password,
                                 email=None, **extra_fields)


class Users(AbstractUser):
    """
    add mobile,email_active django users models.
    """

    REQUIRED_FIELDS = ['phone']
    objects = UserManager()

    phone = models.CharField(max_length=11, unique=True, help_text='手机号码', verbose_name='手机号码',
                             error_messages={
                                 'unique': "此手机号已经注册"},
                             )
    email_active = models.BooleanField(default=False, verbose_name='邮箱验证码状态')

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username
